import React from 'react';
import { BrowserRouter as Router, Route, Routes, Navigate } from 'react-router-dom';
import Login from './pages/Login';
import Register from './pages/Register';
import MainLayout from "./pages/MainLayout";

// 模拟用户登录状态，实际项目中需要替换为真实的登录状态
const isAuthenticated = true;

// 自定义私有路由组件
const PrivateRoute = ({ element, ...rest }) => {
    return isAuthenticated ? (
        element
    ) : (
        <Navigate to="/login" replace state={{ from: rest.location }} />
    );
};

const App = () => {
    return (
        <Router>
            <Routes>
                {/* 公共页面 */}
                <Route path="/login" element={<Login />} />
                <Route path="/register" element={<Register />} />

                {/* 私有页面 */}
                <Route path="/*" element={<MainLayout />} />
            </Routes>
        </Router>
    );
};

export default App;
